// app.js
App({
  globalData: {
    selected: 0,
    cartList: [],
    // baseURL:"http://192.168.1.62:18080",
    // baseURL:"http://192.168.1.59:48080",
    baseURL: "https://api.saas.jzq18.com",
    // baseURL:"http://47.108.168.50:48080",
    accessToken: "",
    expiresTime: "",
    refreshToken: "",
    userId: "",
  },
  onLaunch(options) {
    const scene = decodeURIComponent(options.query.scene);
    const sceneNum = scene.split("=");
    if (scene !== "undefined") {
      wx.setStorageSync("scene", sceneNum[1]);
    } else {
      console.log("直接登录");
    }
    const token = wx.getStorageSync("token");
    const refreshToken = wx.getStorageSync("refreshToken");
    if (token !== "" && refreshToken !== "") {
      wx.switchTab({
        url: options.path,
      });
      if (options.path == "pages/index/index") {
        this.globalData.selected = 0;
      } else if (options.path == "pages/category/category") {
        this.globalData.selected = 1;
      } else if (options.path == "pages/order/order") {
        this.globalData.selected = 2;
      } else if (options.path == "pages/home/home") {
        this.globalData.selected = 3;
      }
    } else if (token == "" || refreshToken == "") {
      wx.switchTab({
        url: "pages/index/index",
      });
      this.globalData.selected = "0";
    } else {
      wx.switchTab({
        url: "pages/index/index",
      });
    }
  },
  onShareAppMessage() {
    return {
      title: "自定义转发标题",
      path: "/pages/index/index",
      imageUrl:
        "https://jiazhiqin.oss-cn-chengdu.aliyuncs.com/mini-program/commen/wechat.png",
    };
  },
});
